package code.ws_common_scene.mode
{
	import code.ws_common_scene.eft.Effects;
	import code.ws_common_scene.mode.inters.ISprite;
	
	import flash.geom.Point;
	
	import starling.display.Sprite;
	import starling.text.TextField;
	import starling.utils.Color;
	import starling.utils.HAlign;

	/**
	 *  传送阵
	 * @author qiangchen
	 * 
	 */	
	public class Trans extends Sprite implements ISprite
	{
		/** id */
		private var _showid:int;
		/** 特效播放器 */
		private var _view:Effects = null;
		/** 下一个场景的名字 */
		private var _nextMapName:String;
		/** 下一个场景的id */
		private var _nextMapId:String;
		/** 下一个场景名字文本 */
		private var _name:TextField = null;
		/** 逻辑点 */
		private var _tile:Point = null;
		
		
		/**
		 * 构造函数 
		 * @param style 皮肤样式
		 * @param p 格子
		 * @param nextMapName 下一个场景的名字
		 * @param nextMapId 下一个场景的id
		 */		
		public function Trans( style:String, p:Point, nextmapName:String, nextmapId:String )
		{
			this.touchable = true;
			
			this.tiles = p;
			this._nextMapName = nextmapName;
			this._nextMapId = nextmapId;
			
			_view = new Effects( style, style + "," + p.x + "|" + p.y );
			_view.touchable = true;
			_view._viewClip.touchable = true;
			addChild( _view );
			
			_name = new TextField( 200, 24,  "☞ " + this._nextMapName, "Verdana", 14, Color.WHITE, true );
			_name.touchable = false;
			_name.hAlign = HAlign.CENTER;
			_name.x = -_name.width >> 1;
			_name.y = 40;
			addChild( _name );
		}
		
		
		/**
		 * 设置、获取逻辑点 
		 * @param p
		 * 
		 */		
		public function set tiles( p:Point ):void
		{
			_tile = p;
		}
		public function get tiles():Point
		{
			return _tile;	
		}
		
		
		/**
		 * 刷新 
		 * 
		 */		
		public function refresh():void
		{
			if( _view )
			{
				_view.refresh();
			}
		}
		
		
		/**
		 * 设置id 
		 * @param val
		 * 
		 */		
		public function set showid( val:int ):void
		{
			_showid = val;
		}
		public function get showid():int
		{
			return _showid;
		}
		
		
		/**
		 * 下一个场景的名字
		 * @return 
		 * 
		 */		
		public function get nextMapName():String
		{
			return _nextMapName;	
		}
		
		
		/**
		 * 下一个场景的id
		 * @return 
		 * 
		 */		
		public function get nextMapId():String
		{
			return _nextMapId;
		}
		
		
		
		/**
		 * 释放 
		 * 
		 */		
		override public function dispose():void
		{
			_view.dispose();
			super.dispose();
		}
	}
}